package D12_9z.xml练习题.xml解析_1;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.List;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        SAXReader saxReader = new SAXReader();
        Document read = saxReader.read("src/Y2019/M12_/D12_9/xml练习题/xml解析_1/city.xml");
        Element root = read.getRootElement();
        List<Element> city = root.elements("city");
        for (Element element : city) {
             System.out.println("cityid："+element.attributeValue("id"));
             System.out.println("cityname："+element.elementText("cityname"));
             System.out.println("cityarea："+element.elementText("cityarea"));
             System.out.println("population："+element.elementText("population"));

        }
    }
}
